package com.chenfan.magic.feign;

import com.chenfan.common.config.Constant;
import com.chenfan.common.vo.Response;
import com.chenfan.common.vo.ResponseCode;
import com.chenfan.magic.constant.TokenConstant;
import com.chenfan.magic.entity.DataGroupDto;
import com.chenfan.magic.entity.SPrivilegeRes;
import com.chenfan.privilege.api.PrivilegeUserRemoteServer;
import com.chenfan.privilege.request.SUserVOReq;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author liuming
 */
@FeignClient(name = "chenfan-cloud-privilege",url = "${feign.privilege:}")
public interface PrivilegeServer extends PrivilegeUserRemoteServer {

    /**
     * 查询菜单权限
     * @param token
     * @param appKey
     * @return
     */
    @GetMapping(value = "/users/resourcesByKey")
    Response getUserResources(@RequestHeader(Constant.AUTHORIZATION_TOKEN) String token, @RequestHeader(TokenConstant.APP_KEY) String appKey);

    /**
     * 获取数据组
     *
     * @param token
     * @param appKey
     * @return
     */
    @ApiOperation(value = "获取数据组", notes = "返回对象[List<DataGroup>]")
    @GetMapping(value = "/dataGroup/listByAppKey")
    Response<List<DataGroupDto>> listByAppId(@RequestHeader(Constant.AUTHORIZATION_TOKEN) String token,
                                             @RequestParam("appKey") String appKey);

    /**
     * 获取全部用户
     * @param userVoReq
     * @return
     */
    @Override
    @ApiOperation(value = "获取全部用户", notes = "获取全部用户")
    @GetMapping(value = "/users/listUsers")
    Response listUsers(@RequestBody SUserVOReq userVoReq);

    /**
     * 权限查询列表
     * @param code
     * @return
     */
    @ApiOperation(value = "权限查询列表", notes = "权限查询列表")
    @GetMapping(value = "/privilege/getListByCode")
    Response<List<SPrivilegeRes>> getListByCode(@RequestParam("code") String code);
}